﻿using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace BenchMarkTest
{
    /// <summary>
    /// 冷热启动
    /// </summary>
    //[SimpleJob(launchCount: 2, warmupCount: 2, targetCount: 3)]
    [SimpleJob(RunStrategy.ColdStart, launchCount: 1, iterationCount: 4)]
    public class WarmAndColdStart
    {
        private bool firstCall;

        [Benchmark]
        public void Foo()
        {
            if (firstCall == false)
            {
                firstCall = true;
                Console.WriteLine("// First call");
                Thread.Sleep(100);
            }
            else
                Thread.Sleep(10);
        }
    }
}
